export default function formatTime(date) {
  const now = Date.now()
  const diff = now - new Date(date).getTime()
  
  const minute = 60 * 1000
  const hour = 60 * minute
  const day = 24 * hour
  const week = 7 * day
  
  if (diff < minute) return '刚刚'
  if (diff < hour) return `${Math.floor(diff/minute)}分钟前`
  if (diff < day) return `${Math.floor(diff/hour)}小时前`
  if (diff < week) return `${Math.floor(diff/day)}天前`
  
  const d = new Date(date)
  return `${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()}`
} 